package com.pig.service.impl;

import com.pig.annotation.RequiredLog;
import com.pig.dao.LogMapper;
import com.pig.pojo.log.Logs;
import com.pig.pojo.user.User;
import com.pig.service.LogService;
import com.pig.util.SysResultLayui;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LogServiceImpl implements LogService {
    @Autowired
    private LogMapper logMapper;
    /**分页查询展现日志*/
    @Override
    @RequiredLog(operation = "分页查询展现日志")
    public SysResultLayui findPageObjects(int page, int limit) {
        int startIndex = (page - 1) * limit;
        int count = logMapper.selectCount(null);
        List<Logs> itemList = logMapper.findUserByPage(startIndex, limit);
        return new SysResultLayui(200, "OK", count, itemList);
    }

    /**
     * 保存用户行为日志
     */
    @Override
    public void saveObject(Logs log) {
        int row = logMapper.insertUserLogs(log);
    }

}
